<?php require_once '../util/verifyMenu.php';?>
<?php require_once '../util/verifyLogin.php';?>
<?php require_once '../util/header.php';?>
<?php require_once '../util/listbus.php';?>
<body>
<div class="mycontent" align="center">
<img src="public/img/header.png" style="width: 1024px; margin: -6px;">
<?php require_once '../util/menu.php';?>
<div align="left">
&nbsp;&nbsp;&nbsp;ยอดซื้อ <b><?php echo $_SESSION['profit'];?></b> บาท&nbsp;&nbsp;&nbsp;
<input type="button" class="btn btn-info" value="ดูประวัติการซื้อ" style="margin-right: 20px;" onclick="javascript:location.href='../control/buydetailControl.php'">
<span style="float: right;">
สวัสดี คุณ <b><?php echo $_SESSION['name']." ".$_SESSION['lastname'];?></b>&nbsp;&nbsp;&nbsp;
<input type="button" class="btn" value="ออกจากระบบ" style="margin-right: 20px;" onclick="javascript:location.href='../util/logout.php'">
</span>
</div>
<h2>Lend Ticket</h2>
<hr>
<h2>เดินทาง วันที่ <?php
$_SESSION['date'] = $_POST['date'];
$t = preg_replace("/:/", " ", $_POST['time']);
$tt = preg_replace("/;/", "-", $t);
echo $_POST['date']." , รอบ".$tt;?></h2>
<?php
	echo "<table class='table' style='width:85%;' align='center'>";
	echo "<th>ลำดับ</th><th>เส้นทาง</th><th>เวลารถออกจากสถานี</th><th>เวลารถถึงจุดหมายปลายทาง</th><th>ประเภท</th><th>ราคา</th><th>เลือก</th>";
	for ($i = 0; $i < count($listBus); $i++) {
		echo "<tr>";
		echo "<td>".($i+1)."</td>";
		echo "<td>".$listBus[$i]->route."</td>";
		echo "<td>".$listBus[$i]->xtime."</td>";
		echo "<td>".$listBus[$i]->ytime."</td>";
		echo "<td>".$listBus[$i]->type."</td>";
		echo "<td>".$listBus[$i]->price."</td>";
		echo "<td><input type='button' class='btn btn-success' value='เลือกที่นั่ง' onclick='location.href=\"../control/lendControl.php?route=".$listBus[$i]->route."&xtime=".$listBus[$i]->xtime."&ytime=".$listBus[$i]->ytime."&type=".$listBus[$i]->type."&price=".$listBus[$i]->price."\"'></td>";
		echo "</tr>";
	}
	echo "</table>";
	require_once '../util/footer.php';
?>

</div>
</body>
